<script>
import { TokenManager } from '@/utils/token'
import { UserInfoManager } from '@/utils/userInfo'
import { useOutsideAppStore } from '@/store/app'

export default {
  async onLaunch() {
    const token = TokenManager.getToken()
    const userInfo = UserInfoManager.getUserInfo()
    const appStore = useOutsideAppStore()

    if (!token || !userInfo) {
      uni.reLaunch({ url: '/pages/login/login' })
      return
    }

    appStore.setUserInfo(userInfo)
    if (UserInfoManager.lastrole() === 1) {
      uni.reLaunch({ url: '/driver/orderHall/index' })
    } else {
      uni.reLaunch({ url: '/user/home/index' })
    }
  },
  onShow() {
    console.log('App Show')
  },
  onHide() {
    console.log('App Hide')
  }
}
</script>

<style lang="scss">
  @import '@/static/style/reset.scss';
  /*每个页面公共css */
  @import 'nutui-uniapp/styles/index.scss';
  page {
    background-color: #f8f8f8;
  }
  // 去除scroll-view的滚动条
  ::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
    background: transparent;
  }
  .scroll-view{
    height: calc(100vh - 180rpx);
  }
    /* 强制覆盖uv-button的背景色 */
    :deep(.submit-btn .uv-button) {
    background-color: #ff6b35 !important;
    border: none !important;
  }

  :deep(.submit-btn .uv-button--primary) {
    background-color: #ff6b35 !important;
    border: none !important;
  }

  .submit-btn-custom {
    width: 100%;
    height: 88rpx;
    background-color: #ff6b35;
    border: none;
    border-radius: 44rpx;
    color: #fff;
    font-size: 32rpx;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4rpx 12rpx rgba(255, 107, 53, 0.3);
  }
  :deep(.uv-action-sheet__item-wrap) {
    max-height: 50vh;
    overflow: auto;
  }
</style>
